package com.etoak.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置邮件队列
 */
@Configuration
public class EmailQueueConfig {
    public static final String EXCHANGE = "email";
    public static final String QUEUE = "email";
    public static final String KEY = "email";

    @Bean
    public DirectExchange emailExchange() {
        return new DirectExchange(EXCHANGE);
    }

    @Bean
    public Queue emailQueue() {
        return new Queue(QUEUE);
    }

    @Bean
    public Binding emailBinding(Queue emailQueue,DirectExchange emailExchange) {
        return BindingBuilder.bind(emailQueue).to(emailExchange).with(KEY);
    }
}
